﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Windows.Resources;
using System.IO;
using System.Diagnostics;

namespace MockSmtpServer
{
    /// <summary>
    /// Interaction logic for AboutWindow.xaml
    /// </summary>
    public partial class AboutWindow : Window
    {
        public AboutWindow()
        {
            InitializeComponent();

            Uri resourceUri = new Uri(@"Resources/mail.ico", UriKind.Relative);
            StreamResourceInfo resourceInfo = Application.GetResourceStream(resourceUri);
            Stream resourceStream = resourceInfo.Stream;

            // Look for the 48x48 icon 
            IconBitmapDecoder iconBitmapDecoder = new IconBitmapDecoder(resourceStream, BitmapCreateOptions.None, BitmapCacheOption.OnDemand);
            if (iconBitmapDecoder.Frames.Count > 1)
            {
                foreach (BitmapFrame bitmapFrame in iconBitmapDecoder.Frames)
                {
                    if (bitmapFrame.Height == 48 
                        && bitmapFrame.Width == 48 
                        && bitmapFrame.Format.BitsPerPixel == 32)
                    {
                        image.Source = bitmapFrame;
                        break;
                    }
                }
            }
        }

        private void FlowDocument_Click(object sender, RoutedEventArgs e)
        {
            Process.Start("http://MockSmtpServer.CodePlex.com");
            e.Handled = true;
        }
    }
}
